#ifndef NETWORKHTTPREQUEST_H
#define NETWORKHTTPREQUEST_H

#include "networkrequest.h"

#include <QMetaObject>


class QNetworkAccessManager;
class QNetworkReply;
class QUrl;

namespace Network {

class Response;

class HttpRequest : public Request
{
    Q_OBJECT
public:
    explicit HttpRequest();

public:
    bool post(Manager *manager);
    void abort();

private:
    virtual QNetworkReply *post(QNetworkAccessManager &manager, const QUrl &url) const = 0;
    virtual QUrl url() const = 0;
    virtual Response &response() = 0;

public:
    virtual const Response &response() const = 0;

signals:
    void responded(HttpRequest *request);

private slots:
    void replied();

private:
    QNetworkReply *m_reply;
    QMetaObject::Connection m_connection;
};

} // namespace Network

#endif // NETWORKHTTPREQUEST_H
